
import React, { Component } from "react";
import PropTypes from "prop-types"
import './index.css'
class MyHeader extends Component {
    static propTypes = {
        setItems: PropTypes.func.isRequired
    }
    state = {
        searchText: ''
    }
    keyUp = (event) => {
        let { target, keyCode } = event
        if (keyCode !== 13 || !target.value) return

        this.props.setItems(target.value)
        target.value = ''
    }

    render() {
        return (<div className="header-container">
            <input onKeyUp={this.keyUp} type="text" placeholder="请输入" className="inp"></input>
        </div>)
    }
}
export default MyHeader